<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加系统用户</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../static/layui/css/layui.css" media="all">
</head>
<body>

<form id="myform" class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <input type="hidden" name="id">
    <!--    &lt;!&ndash;id&ndash;&gt;-->
    <!--    <div class="layui-form-item">-->
    <!--        <label class="layui-form-label required">会员id</label>-->
    <!--        <div class="layui-input-inline">-->
    <!--            <input type="text" id="memberNumber" name="memberNumber" lay-verify="required" placeholder="请输入会员id" autocomplete="off" class="layui-input">-->
    <!--        </div>-->
    <!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label required">会员姓名</label>
        <div class="layui-input-inline">
            <input type="text" id=memberName" name="memberName" lay-verify="required" placeholder="请输入会员姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">会员类型</label>
        <div class="layui-input-inline">
            <input type="text" id=memberType" name="memberType" lay-verify="required" placeholder="请输入会员类型" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">会员密码</label>
        <div class="layui-input-inline">
            <input type="password" id=memberPassword" name="memberPassword" lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <!--性别-->
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="memberSex"  value="1" title="男">
            <input type="radio" name="memberSex"  value="2" title="女">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">生日</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="memberBirth"  id="memberBirth" readonly placeholder="请输入生日">
            </div>
        </div>
    </div>
    <!--会员电话-->
    <div class="layui-form-item">
        <label class="layui-form-label">会员电话</label>
        <div class="layui-input-inline">
            <input type="text" name="memberPhone" placeholder="请输入会员电话" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">会员地址</label>
        <div class="layui-input-inline">
            <input type="text" name="memberAddress" placeholder="请输入会员地址" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">办理时间</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="memberStartTime"  id="memberStartTime" readonly placeholder="请输入办理时间">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">到期时间</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="memberEndTime"  id="memberEndTime" readonly placeholder="请输入到期时间">
            </div>
        </div>
    </div>

    <!--确认提交-->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-back-submit" >确认</button>
            <button type="reset" class="layui-btn">重置</button>
        </div>
    </div>
    </div>
</form>

<!--引入本地layui.js-->
<script src="../static/layui/layui.js"></script>
<!--js-->
<script type="text/javascript">
    layui.config({
        base: '../static/layui/layuiadmin/' //静态资源所在路径js
    }).extend({
        index: 'lib/index' //主入口模块
    }).use('index');
</script>
<!--表单验证和调用接口传参-->
<script>
    layui.use(['form', 'layedit', 'laydate','layer'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;
        form.verify({

        });
        // 初始化laydate时间控件
        laydate.render({
            elem: '#memberBirth',
            type: 'datetime',
            trigger: 'click',

        });

        laydate.render({
            elem: '#memberStartTime',
            type: 'datetime',
            trigger: 'click',

        });

        laydate.render({
            elem: '#memberEndTime',
            type: 'datetime',
            trigger: 'click',

        });
        form.on('submit',function (data) {
            let memberName = $("input[name='memberName']").val();
            let memberPassword = $("input[name='memberPassword']").val();
            let memberSex = $("input[name='memberSex']").val();
            let memberBirth = $("input[name='memberBirth']").val();
            let memberPhone = $("input[name='memberPhone']").val();
            let memberStartTime = $("input[name='memberStartTime']").val();
            let memberEndTime = $("input[name='memberEndTime']").val();
            $.ajax({
                type: "post",
                url: "http://localhost:8181/member/updateMemberById",
                data: JSON.stringify(data.field),
                dataType: "json",
                contentType:'application/json',
                success: function (res) {
                    if(res.code == 200){//code=200登录成功
                        //1.弹出提示信息
                        layer.msg('添加成功',{
                            offset:'15px',
                            icon:1,
                            time:1000
                        },function () {
                            window.parent.location.reload();
                        });
                    }else {
                        layer.msg('添加失败',{
                            offset:'15px',
                            icon:1,
                            time:1000
                        },function () {
                            window.location.href = "memberAdd.html"
                        });
                    }
                }
            })
            return false;
        })
        /*:form.on()表单监控事件中一定要加 return false;
        如果不加的话,后端不会报错,而前端代码中不会运行到success中,
        不同浏览器也有不同效果,谷歌浏览器有时会报错,火狐和其他浏览器100%报错*/

    })
    //Demo


</script>
<script src="../static/js/jquery-3.6.0.min.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->


</body>
</html>


</body>
</html>